package com.kingzoon.seckill.service.impl;

import java.util.HashMap;

import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import ch.qos.logback.classic.Logger;

import com.kingzoon.seckill.dto.Exposer;
import com.kingzoon.seckill.dto.Result;
import com.kingzoon.seckill.enums.MacroDefine;
import com.kingzoon.seckill.service.TestService;

@Service
public class TestServiceImpl implements TestService {
	
	protected Logger log = (Logger) LoggerFactory.getLogger(TestServiceImpl.class);
	
	private HashMap<String,Object> paramMap = new HashMap<String,Object>();
	
	public Result<Exposer> doBusiness(HashMap<String,Object> mapParam,Result<Exposer> rs) {
		paramMap = mapParam;
		if(preCheck(rs)){
			if(cache(rs)){
				if(check(rs)){
					if(before(rs)){
						if(clear(rs)){
							after(rs);
						}
					}
				}
			}
		}
		return rs;
	}

	public boolean preCheck(Result<Exposer> rs) {
		log.debug("入参校验");
		return true;
	}

	public boolean cache(Result<Exposer> rs) {
		log.debug("设置缓存");
		return true;
	}

	public boolean check(Result<Exposer> rs) {
		log.debug("业务校验");
		return true;
	}

	public boolean before(Result<Exposer> rs) {
		log.debug("业务处理前设置");
		return true;
	}

	public boolean clear(Result<Exposer> rs) {
		Exposer date = new Exposer(true, "md5值", 1001);
		rs.setFlag(true);
		rs.setCode(MacroDefine.JC_CODE.S_0000.getCode());
		rs.setMessage(MacroDefine.JC_CODE.S_0000.getMessage());
		rs.setData(date);
		log.debug("业务逻辑");
		return true;
	}

	public boolean after(Result<Exposer> rs) {
		log.debug("业务处理后设置");
		return true;
	}

}
